<%--
  Created by IntelliJ IDEA.
  User: CY
  Date: 2018/4/14
  Time: 17:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%  String point=(String) request.getSession().getAttribute("coordinatePoint");%>
<html>
<head>
    <title>地图demo</title>
    <style>
        #map{
            width:100%;
            height:100%;
        }
    </style>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=YECw4heQ9wzy7RKg8OW9QLMsySKzQRan"></script>
</head>
<body>
    <div id="map"></div>
    <script>
        var map = new BMap.Map('map');
      //  var point = new BMap.Point(116.669862,40.116349); //创建点坐标
        var point = new BMap.Point(<%=point%>); //创建点坐标
        map.centerAndZoom(point,15); //创建中心点和地图级别，初始化
        map.enableScrollWheelZoom();
//
//        var polyline = new BMap.Polyline([
//            new BMap.Point(116.669012,40.122727),
//            new BMap.Point(116.672425,40.121961),
//            new BMap.Point(116.672183,40.120279),
//            new BMap.Point(116.67106,40.120285),
//            new BMap.Point(116.670853,40.118416),
//            new BMap.Point(116.668994,40.118478)
//        ],{strokeColor:"blue", strokeWeight:1, strokeOpacity:0.5})
//        map.addOverlay(polyline)
        var arr = str .split('|');
//        console.log(arr)
        var polygon = new BMap.Polygon(function(){
            var arrTwo=[];
            for(var i=0;i<arr.length;i++){
                var type =arr[i].split(',')
                var no=new BMap.Point(type[0],type[1]);
                arrTwo.push(no)
            };
            return arrTwo;
        }(), {strokeColor:"blue", strokeWeight:2, strokeOpacity:0.5});  //创建多边形
        map.addOverlay(polygon);

    </script>
</body>
</html>
